# Importing Data
HUNGARY<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "P1:P229")

# Checking the Imported Data
View(HUNGARY)
# Creating Time Series Data
HUNGARY_ts <- ts(HUNGARY, start=c(1998,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
HUNGARY_ts
sum(is.na(HUNGARY_ts))
library(forecast)
HUNGARY_ts <- tsclean(HUNGARY_ts)
HUNGARY_ts

# Identification: Plotting the Time Series Data
plot(HUNGARY_ts)

# Estimating the appropriate model
HUNGARY_ts_model <- auto.arima(HUNGARY_ts)
HUNGARY_ts_model

# Forecasting
options(max.print=1000000)
HUNGARY_ts_forecast <- forecast (HUNGARY_ts_model, level=c(95), h=288)
plot(HUNGARY_ts_forecast)
HUNGARY_ts_forecast             

# Exporting
write.table(HUNGARY_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/HUNGARY_TSA.csv", sep=",")
